package com.huawei.hianalytics.ab.fg;

import android.content.Context;
import android.text.TextUtils;
import com.huawei.hianalytics.ab.bc.cd.ab.ab;
import com.huawei.hianalytics.ab.bc.cd.ab.ef;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.util.LinkedHashMap;
import java.util.Map;

public class cd {
    public ef ab;
    private String bc;

    public cd(String str) {
        this.bc = str;
        this.ab = new ef(str);
        ab.ab().ab(this.bc, this.ab);
    }

    private com.huawei.hianalytics.ab.bc.cd.ab.cd bc(int i) {
        switch (i) {
            case 0:
                return this.ab.bc();
            case 1:
                return this.ab.ab();
            case 2:
                return this.ab.cd();
            case 3:
                return this.ab.de();
            default:
                return null;
        }
    }

    private boolean cd(int i) {
        if (i != 2) {
            com.huawei.hianalytics.ab.bc.cd.ab.cd bc = bc(i);
            if (bc != null && !TextUtils.isEmpty(bc.hi())) {
                return true;
            }
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "verifyURL(): URL check failed. type: " + i);
            return false;
        } else if ("_default_config_tag".equals(this.bc)) {
            return true;
        } else {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "verifyURL(): type: preins. Only default config can report Pre-install data.");
            return false;
        }
    }

    public void ab(int i) {
        com.huawei.hianalytics.ab.bc.ef.ab.ab("hmsSdk", "HiAnalyticsInstance.onReport() is execute.TAG: %s,TYPE: %d", this.bc, Integer.valueOf(i));
        bc.ab().ab(this.bc, i);
    }

    public void ab(int i, com.huawei.hianalytics.ab.bc.cd.ab.cd cdVar) {
        com.huawei.hianalytics.ab.bc.cd.ab.cd cdVar2 = null;
        if (cdVar == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.ab("hmsSdk", "HiAnalyticsInstanceImpl.refresh(). Parameter config is null.TAG : %s , TYPE : %d", this.bc, Integer.valueOf(i));
        } else {
            cdVar2 = new com.huawei.hianalytics.ab.bc.cd.ab.cd(cdVar);
        }
        com.huawei.hianalytics.ab.bc.ef.ab.ab("hmsSdk", "HiAnalyticsInstanceImpl.refresh() is executed.TAG : %s , TYPE : %d", this.bc, Integer.valueOf(i));
        switch (i) {
            case 0:
                cd(cdVar2);
                com.huawei.hianalytics.ab.bc.hi.ab.ab().ab(this.bc);
                return;
            case 1:
                ab(cdVar2);
                return;
            case 2:
                de(cdVar2);
                return;
            case 3:
                bc(cdVar2);
                return;
            default:
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "refresh(): HiAnalyticsType can only be OPERATION ,MAINTAIN or DIFF_PRIVACY.");
                return;
        }
    }

    public void ab(int i, String str) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstanceImpl.setUpid() is executed.TAG : " + this.bc);
        com.huawei.hianalytics.ab.bc.cd.ab.cd bc = bc(i);
        if (bc == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "setUpid(): No related config found.type : " + i);
            return;
        }
        if (!com.huawei.hianalytics.ab.bc.kl.cd.ab("upid", str, 4096)) {
            str = "";
        }
        bc.fg(str);
    }

    public void ab(int i, String str, LinkedHashMap<String, String> linkedHashMap) {
        com.huawei.hianalytics.ab.bc.ef.ab.ab("hmsSdk", "HiAnalyticsInstance.onEvent(int type, String eventId, Map<String, String> mapValue) is execute.TAG: %s,TYPE: %d", this.bc, Integer.valueOf(i));
        if (com.huawei.hianalytics.ab.bc.kl.cd.ab(str) || !cd(i)) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onEvent() parameters check fail. Nothing will be recorded.TAG: " + this.bc + ", TYPE: " + i);
            return;
        }
        LinkedHashMap linkedHashMap2;
        if (!com.huawei.hianalytics.ab.bc.kl.cd.ab((Map) linkedHashMap)) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onEvent() parameter mapValue will be cleared.TAG: " + this.bc + ", TYPE: " + i);
            linkedHashMap2 = null;
        }
        bc.ab().ab(this.bc, i, str, linkedHashMap2);
    }

    public void ab(int i, boolean z) {
        com.huawei.hianalytics.ab.bc.ef.ab.ab("hmsSdk", "HiAnalyticsInstanceImpl.setOAIDTrackingFlag() is executed.TAG : %s , TYPE : %d", this.bc, Integer.valueOf(i));
        com.huawei.hianalytics.ab.bc.cd.ab.cd bc = bc(i);
        if (bc == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "setOAIDTrackingFlag(): No related config found.type : " + i);
        } else {
            bc.de(z ? "true" : "false");
        }
    }

    public void ab(Context context) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstance.onPause() is execute.TAG: " + this.bc);
        if (context == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "context is null in onPause! Nothing will be recorded.TAG: " + this.bc);
        } else if (cd(0)) {
            bc.ab().ab(this.bc, context);
        } else {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() URL check fail. Nothing will be recorded.TAG: " + this.bc);
        }
    }

    public void ab(Context context, int i) {
        com.huawei.hianalytics.ab.bc.ef.ab.ab("hmsSdk", "HiAnalyticsInstance.onReport(Context context) is execute.TAG: %s,TYPE: %d", this.bc, Integer.valueOf(i));
        if (context == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "context is null in onReport!");
        } else {
            bc.ab().ab(this.bc, i);
        }
    }

    public void ab(Context context, String str, String str2) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstance.onEvent(eventId, mapValue) is execute.TAG : " + this.bc);
        if (context == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "context is null in onevent ");
        } else if (com.huawei.hianalytics.ab.bc.kl.cd.ab(str) || !cd(0)) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onEvent() parameters check fail. Nothing will be recorded.TAG: " + this.bc);
        } else {
            if (!com.huawei.hianalytics.ab.bc.kl.cd.ab("value", str2, (int) WXMediaMessage.THUMB_LENGTH_LIMIT)) {
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onEvent() parameter VALUE is overlong, content will be cleared.TAG: " + this.bc);
                str2 = "";
            }
            bc.ab().ab(this.bc, context, str, str2);
        }
    }

    public void ab(Context context, LinkedHashMap<String, String> linkedHashMap) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstance.onPause(context,map) is execute.TAG: " + this.bc);
        if (context == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "context is null in onPause! Nothing will be recorded.");
        } else if (cd(0)) {
            LinkedHashMap linkedHashMap2;
            if (!com.huawei.hianalytics.ab.bc.kl.cd.ab((Map) linkedHashMap)) {
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onPause() parameter mapValue will be cleared.TAG: " + this.bc);
                linkedHashMap2 = null;
            }
            bc.ab().ab(this.bc, context, linkedHashMap2);
        } else {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() URL check fail. Nothing will be recorded.TAG: " + this.bc);
        }
    }

    public void ab(com.huawei.hianalytics.ab.bc.cd.ab.cd cdVar) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstanceImpl.setMaintConf() is executed.TAG : " + this.bc);
        if (cdVar == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "HiAnalyticsInstanceImpl.setMaintConf(): config for maint is null!");
            this.ab.ab(null);
            return;
        }
        this.ab.ab(cdVar);
    }

    public void ab(String str, LinkedHashMap<String, String> linkedHashMap) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstance.onPause(viewName,map) is execute.TAG: " + this.bc);
        if (!cd(0)) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onPause() URL check fail. Nothing will be recorded.TAG: " + this.bc);
        } else if (TextUtils.isEmpty(str) || !com.huawei.hianalytics.ab.bc.kl.cd.ab("viewName", str, "[a-zA-Z_][a-zA-Z0-9. _-]{0,255}")) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onPause() parameter viewName verify failed. Nothing will be recorded.TAG: " + this.bc);
        } else {
            LinkedHashMap linkedHashMap2;
            if (!com.huawei.hianalytics.ab.bc.kl.cd.ab((Map) linkedHashMap)) {
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onPause() parameter mapValue will be cleared.TAG: " + this.bc);
                linkedHashMap2 = null;
            }
            bc.ab().ab(this.bc, str, linkedHashMap2);
        }
    }

    public void bc(int i, String str) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstanceImpl.setStrOAID() is executed.TAG : " + this.bc);
        com.huawei.hianalytics.ab.bc.cd.ab.cd bc = bc(i);
        if (bc == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "setOAID(): No related config found.type : " + i);
            return;
        }
        if (!com.huawei.hianalytics.ab.bc.kl.cd.ab("oaid", str, 4096)) {
            str = "";
        }
        bc.cd(str);
    }

    public void bc(int i, String str, LinkedHashMap<String, String> linkedHashMap) {
        com.huawei.hianalytics.ab.bc.ef.ab.ab("hmsSdk", "HiAnalyticsInstance.onStreamEvent() is execute.TAG: %s,TYPE: %d", this.bc, Integer.valueOf(i));
        if (com.huawei.hianalytics.ab.bc.kl.cd.ab(str) || !cd(i)) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onStreamEvent() parameters check fail. Nothing will be recorded.TAG: " + this.bc + ", TYPE: " + i);
            return;
        }
        LinkedHashMap linkedHashMap2;
        if (!com.huawei.hianalytics.ab.bc.kl.cd.ab((Map) linkedHashMap)) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onStreamEvent() parameter mapValue will be cleared.TAG: " + this.bc + ", TYPE: " + i);
            linkedHashMap2 = null;
        }
        bc.ab().bc(this.bc, i, str, linkedHashMap2);
    }

    public void bc(Context context) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstance.onResume() is execute.TAG: " + this.bc);
        if (context == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "context is null in onResume! Nothing will be recorded.");
        } else if (cd(0)) {
            bc.ab().bc(this.bc, context);
        } else {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() URL check fail. Nothing will be recorded.TAG: " + this.bc);
        }
    }

    public void bc(Context context, LinkedHashMap<String, String> linkedHashMap) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstance.onResume(context,map) is execute.TAG: " + this.bc);
        if (context == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "context is null in onResume! Nothing will be recorded.");
        } else if (cd(0)) {
            LinkedHashMap linkedHashMap2;
            if (!com.huawei.hianalytics.ab.bc.kl.cd.ab((Map) linkedHashMap)) {
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() parameter mapValue will be cleared.TAG: " + this.bc);
                linkedHashMap2 = null;
            }
            bc.ab().bc(this.bc, context, linkedHashMap2);
        } else {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() URL check fail. Nothing will be recorded.TAG: " + this.bc);
        }
    }

    public void bc(com.huawei.hianalytics.ab.bc.cd.ab.cd cdVar) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstanceImpl.setDiffConf() is executed.TAG : " + this.bc);
        if (cdVar == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "HiAnalyticsInstanceImpl.setDiffConf(): config for diffPrivacy is null!");
            this.ab.de(null);
            return;
        }
        this.ab.de(cdVar);
    }

    public void bc(String str, LinkedHashMap<String, String> linkedHashMap) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstance.onResume(viewname,map) is execute.TAG: " + this.bc);
        if (!cd(0)) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() URL check fail. Nothing will be recorded.TAG: " + this.bc);
        } else if (TextUtils.isEmpty(str) || !com.huawei.hianalytics.ab.bc.kl.cd.ab("viewName", str, "[a-zA-Z_][a-zA-Z0-9. _-]{0,255}")) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() parameter viewName verify failed. Nothing will be recorded.TAG: " + this.bc);
        } else {
            LinkedHashMap linkedHashMap2;
            if (!com.huawei.hianalytics.ab.bc.kl.cd.ab((Map) linkedHashMap)) {
                com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "onResume() parameter mapValue will be cleared.TAG: " + this.bc);
                linkedHashMap2 = null;
            }
            bc.ab().bc(this.bc, str, linkedHashMap2);
        }
    }

    public void cd(com.huawei.hianalytics.ab.bc.cd.ab.cd cdVar) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstanceImpl.setOperConf() is executed.TAG: " + this.bc);
        if (cdVar == null) {
            this.ab.bc(null);
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "HiAnalyticsInstanceImpl.setOperConf(): config for oper is null!");
            return;
        }
        this.ab.bc(cdVar);
    }

    public void de(com.huawei.hianalytics.ab.bc.cd.ab.cd cdVar) {
        com.huawei.hianalytics.ab.bc.ef.ab.bc("hmsSdk", "HiAnalyticsInstanceImpl.setPreInstallConf() is executed.TAG: " + this.bc);
        if (cdVar == null) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("hmsSdk", "HiAnalyticsInstanceImpl.setPreInstallConf(): config for PRE-INSTALL is null!");
            this.ab.cd(null);
            return;
        }
        this.ab.cd(cdVar);
    }
}
